// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

{namespace e2e.ext.ui.templates.dialogs.importconfirmation}

/**
 * Renders the text for key import confirmation dialog.
 */
{template .importKeyConfirm}
  {@param promptImportKeyConfirmLabel: ?}  /** A sentence asking the user to confirm the key import.
      */
  {@param keys: ?}  /** Array of keys (e2e.openpgp.Keys). */
  {@param secretKeyDescription: ?}  /** Text describing a secret key. */
  {@param publicKeyDescription: ?}  /** Text describing a public key. */
  {@param keyFingerprintLabel: ?}  /** Text to display as a fingerprint label. */
  <p>{$promptImportKeyConfirmLabel}
  </p>
  {for $key in $keys}
    <div class="{e2e.ext.constants.CssClass.KEY_INFO}">
      {for $uid in $key.uids}
      <div class="{e2e.ext.constants.CssClass.KEY_UID}">
        {$uid}
      </div>
      {/for}
      <div>
        {call .keyPacketInfo}
          {param keyPacketInfo: $key.key /}
          {param secretKeyDescription: $secretKeyDescription /}
          {param publicKeyDescription: $publicKeyDescription /}
          {param keyFingerprintLabel: $keyFingerprintLabel /}
        {/call}
      </div>
    </div>
  {/for}
{/template}


/**
 * Renders information about a single key packet.
 */
{template .keyPacketInfo}
  {@param keyPacketInfo: ?}  /** Single packet key info (e2e.openpgp.KeyPacketInfo). */
  {@param secretKeyDescription: ?}  /** Text to display if the key is secret. */
  {@param publicKeyDescription: ?}  /** Text to display if the key is public. */
  {@param keyFingerprintLabel: ?}  /** Text to display as a fingerprint label. */
  <div class="{e2e.ext.constants.CssClass.KEY_META}">
    <span class="{e2e.ext.constants.CssClass.KEY_FINGERPRINT}" title="{$keyFingerprintLabel}">
      {$keyPacketInfo.fingerprintHex}
    </span>{sp}
    ({if $keyPacketInfo.secret}
      {$secretKeyDescription}
    {else}
      {$publicKeyDescription}
    {/if}
    {sp}{$keyPacketInfo.algorithm}
    )
  </div>
{/template}
